<?php
function process(&$req){
     switch($req['wt']){
	     //user related cases:
          case 'ausr':
				  //$html.=var_header();
                  //render('header',$userData);

		$theme['content']=easy_render('adduser');
		$html=render('main',$theme);

				  //$html.=var_footer();
               break;
          case 'iusr':
              $html.=easy_render('header');
              $msg=insert_user($req);
              $html.=$msg;
            break;
          case 'eusr':
               break;
          case 'uusr':
               break;
          case 'rusr':
               break;
          case 'usr':
              echo "hello";
               break;
          case 'susr':
              $qGetAllUsers="select * from users order by num_sol";
              $html.="<table border=1>";
              $html.=get_users( query($qGetAllUsers,0,"","") );
              $html.="</table>";
               break;
          //end of user related cases
          //admin Control panel cases
          case 'out':
               break;
          case 'acp':
               break;
          default:
               $req['do'] = 'susr';
               process(&$req);
			   break;
          //
      }
      return $html;
  }
  function insert_user($req){
      $joinTime=time();
      $req['password']=md5($req['password']);
      $qInsertUser="insert into `users` values (NULL,'{$req['email']}','{$req['real_name']}','{$req['password']}','{$req['tools']}',$joinTime,0,0)";
      //echo "<pre>$qInsertUser</pre>";// trace query
      query($qInsertUser);
      return;
  }
  function get_users($result){
      $usrview=easy_render('user');
     while($user=mysql_fetch_array($result)){
         render_var($userView,$user);
     }
      return $result;
  }
  ?>
